<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>订单支付</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <meta http-equiv="Expires" content="-1">
    <meta http-equiv="Cache-Control" content="no-cache">
    <meta http-equiv="Pragma" content="no-cache">
    <meta name="description" content="！">
    <meta name="Keywords" content="">
    <link rel="stylesheet" href="${contextPath}/staticwx/qs/css/reset.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/qs/css/global.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/qs/css/iconfont.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/qs/css/flex.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/qs/css/order.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/qs/css/address.css">
    <link rel="stylesheet" href="${contextPath}/staticwx/qs/css/popUp.css">
</head>
<body style="background:#efefef">
<div class="main-wrapper">
    <header class="header fixed" id="headTop">
        <div class="hl" onclick="javascript:window.history.go(-1);"><span class="iconfont icon-zuojiantou"></span></div>
        <div class="hc">订单支付</div>
        <div class="hr" onclick="javascript:location.href='${contextPath}/wx/index.htm'"><span class="iconfont icon-home"></span></div>
    </header>
    <#if orderAddr??>
        <div class="address selectAddrBtn" style="margin-top: 1px;">
            <img src="${contextPath}/staticwx/qs/images/addrline.jpg" width="100%" alt="">
            <div class="info">
                <div class="detail">
                    <div class="clearfix">
                        <div class="fl">${orderAddr.realname!}</div>
                        <div class="fr">${orderAddr.tel!}</div>
                    </div>
                    <p>收货地址：${orderAddr.provinceName!}${orderAddr.cityName!}${orderAddr.regionName!}${orderAddr.addr!}</p>
                </div>
            </div>
            <img src="${contextPath}/staticwx/qs/images/addrline.jpg" width="100%" alt="">
        </div>
        <#else>
            <div class="selectAddr selectAddrBtn" style="margin-top: 1px;">
                <span class="fl">收货地址</span><span class="iconfont icon-youjiantou fr"></span>
            </div>
        </#if>

    <!-- 商品详情 1-->
    <div class="shopTit" style="margin-top: 2px;">订单商品</div>
    <ul class="orderList">
        <#list draProList as draProduct>
        <li>
            <img src="${draProduct.coverimg!}" alt="" style="height:75px;">
            <div class="detail">
                <p class="tit tof2">${draProduct.proname!} </p>
                <p class="guig clearfix"><span class="fl">${draProduct.shortname!}</span><span class="fr">×${draProduct.proNum!1}</span></p>
                <p class="price"><span class="new">￥${draProduct.price?string("0.00")}</span><span class="old">￥${draProduct.oldprice?string("0.00")}</span></p>
            </div>
        </li>
        </#list>
    </ul>
    <!-- 支付方式 -->
    <div class="orderTit" style="margin-top:2px;">支付方式</div>
    <ul class="psList">
        <li>
            <img src="${contextPath}/staticwx/qs/images/wechat.png" alt="">
            <div class="detail">
                <p class="tit">微信支付</p>
                <p>推荐微信用户使用</p>
            </div>
            <div class="radioBtn radioBtnCss fl selected" data-paytype="1">
                <span class="iconfont gou"></span>
                <input type="radio" name="choosePs">
            </div>
        </li>
        <#if orderType?? &&orderType!=4>
        <li>
            <img src="${contextPath}/staticwx/qs/images/yue.png" alt="">
            <div class="detail">
                <p class="tit">余额支付</p>
                <p>当前余额：￥${mc.balance?string("0.00")} <#if mc.balance?? && mc.balance lt 100><a href="${contextPath}/wx/member/goCharge.htm" style="margin-left:15px;">充值</a></#if></p>
            </div>
            <div class="radioBtn radioBtnCss fl" data-paytype="2">
                <span class="iconfont gou"></span>
                <input type="radio" name="choosePs">
            </div>
        </li>
        <li>
            <img src="${contextPath}/staticwx/qs/images/jifen.png" alt="">
            <div class="detail">
                <p class="tit">积分支付</p>
                <p>当前积分：${mc.integral}积分</p>
            </div>
            <div class="radioBtn radioBtnCss fl" data-paytype="3">
                <span class="iconfont gou"></span>
                <input type="radio" name="choosePs">
            </div>
        </li>
            </#if>
    </ul>
    <div class="orderTit" style="margin-top: 2px;">订单备注</div>
    <div><textarea name="remark" id="remark" placeholder="请输入您的备注信息" style="border-left-width:0px;margin-top: 0px;margin-bottom: -1px;width:100%;padding-left: 13px;border-style: solid;border-width: 1px;border-color: #f7f3f3;"></textarea></div>

    <div class="moneyToPay" style="margin-top: -5px;">
        <span class="fl">支付金额：</span>
        <span class="fr cred">￥${orderAmount?string("0.00")}</span>
    </div>
    <div class="btnBlock">
        <input type="hidden" name="abId" id="abId" value="${orderAddrId!}"/>
        <input type="hidden" name="orderType" id="orderType" value="${orderType!1}"/>
        <input type="hidden" name="memberId" id="memberId" value="${Session['cur_member_id']!}"/>
        <input type="hidden" name="productAmount" id="productAmount" value="${orderAmount?string('0.00')}"/>
        <input type="hidden" name="totalAmount" id="totalAmount" value="${orderAmount?string('0.00')}"/>
        <input type="hidden" name="orderNo" id="orderNo" value=""/>
        <input type="hidden" name="openId" id="openId" value="${Session['cur_openid']!}"/>
        <input type="hidden" name="cityId" id="cityId" value="${Session['cur_city_id']!}"/>

        <input type="hidden" id="payType" value="1"/>
        <input type="hidden" id="disType" value="1"/>

        <input type="hidden" id="appId" value=""/>
        <input type="hidden" id="timeStamp" value=""/>
        <input type="hidden" id="nonceStr" value=""/>
        <input type="hidden" id="packages" value=""/>
        <input type="hidden" id="paySign" value=""/>
        <button class="submitPayList" style="background-color: #09bb07;" type="button" onclick="subOrder()">提交订单</button>
    </div>

</div>

<div class="addressBlc">
    <header class="addressHead">
        <span class="fr" style="margin-right:40%;">我的地址簿</span>
        <span class="fl close">关闭</span>
    </header>
    <section class="addrList" style="width: 100%;">
        <ul id="addrUl">
            <#list addressList as ad>
            <li id="addrli_${ad.id!}">
                <div class="clearfix">
                    <span class="fl">${ad.realname!}</span>
                    <span class="fr">${ad.tel!}</span>
                </div>
                <p>${ad.provinceName!}${ad.cityName!}${ad.regionName!}${ad.addr!}</p>
                <div class="clearfix">
                    <div class="fl checkarea">
                        <span class="cblue" onclick="sendHere('${ad.id!}','${ad.realname!}','${ad.tel!}','${ad.provinceName!}','${ad.cityName!}','${ad.regionName!}','${ad.isdefault!}','${ad.addr!}')">&nbsp;送到这里去</span>
                    </div>
                    <span class="fr">
                        <span class="editBtn" onclick="editAddr('${ad.id!}','${ad.realname!}','${ad.tel!}','${ad.provinceid!}','${ad.cityid!}','${ad.regionid!}','${ad.isdefault!}','${ad.addr!}')"><span class="iconfont icon-bianji"></span>&nbsp;编辑</span>
                        &nbsp;&nbsp;
                        <span class="delBtn" onclick="addrDelConfirm('${ad.id!}')"><span class="iconfont icon-lajitong"></span>&nbsp;删除</span>
                    </span>
                </div>
            </li>
            </#list>
        </ul>
    </section>
    <section class="addAddr">
        <header class="header">
            <div class="hl"><span class="iconfont icon-zuojiantou"></span></div>
            <div class="hc">收货地址</div>
        </header>
        <form id="addrForm" class="addrForm">
            <ul>
                <li><label for="">收货人</label>
                    <div class="inputArea">
                        <input type="text" placeholder="请输入真实姓名" name="realname" id="realname">
                    </div>
                </li>
                <li><label for="">手机号码</label>
                    <div class="inputArea">
                        <input type="number" placeholder="请输入手机号码" name="tel" id="tel">
                    </div>
                </li>
                <li><label for="">省份</label>
                    <div class="inputArea">
                        <select name="provinceid" id="cprov">
                            <option value="">请选择</option>
                            <#list tagList as tag>
                                <option value="${tag.id!}">${tag.tname}</option>
                            </#list>
                        </select>
                    </div>
                </li>
                <li><label for="">城市</label>
                    <div class="inputArea">
                        <select name="cityid" id="ccity">
                            <option value="">请选择</option>
                        </select>
                    </div></li>
                <li><label for="">区域</label>
                    <div class="inputArea">
                        <select name="regionid" id="cdiv">
                            <option value="">请选择</option>
                        </select>
                    </div>
                </li>
                <li><label for="">详细地址</label>
                    <div class="inputArea">
                        <textarea name="addr" id="cdetail" placeholder="请输入详细地址"cdetail></textarea>
                    </div>
                </li>
            </ul>
            <div class="btnBlock">
                <input type="hidden" name="memberid" id="addrmid" value="${mid!}"/>
                <input type="hidden" name="id" id="addrid" value=""/>
                <input type="hidden" name="isdefault" id="isdefault" value="0"/>
                <button class="submitPayList addrFormSubmit" type="submit">保存</button>
                <input type="hidden"  id="saveType" value="0"/>
                <input type="hidden"  id="delAddrId" value=""/>
            </div>
        </form>

    </section>
    <footer class="addressFoot">
        <button class="addAddrBtn">添加收货地址</button>
    </footer>
    <div class="popUpMask" id="delAddr">
        <div class="popUpBox" flex="cross:center">
            <div class="popUpOuter">
                <div class="popUpContent">
                    <div class="popUpDetail ac">
                        <br>
                        <img src="${contextPath}/staticwx/qs/images/qus.jpg" alt="" style="width: 25%;">
                        <br>
                        <p>确定删除该地址吗？</p>
                        <br>
                        <div class="btngroup clearfix">
                            <div class="btnchild"><button class="btnSubmit" onclick="delAddr();"  type="button">确定</button></div>
                            <div class="btnchild"><button class="btnCancel" type="button">取消</button></div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="${contextPath}/staticwx/qs/js/jquery-3.0.0.min.js" type="text/javascript"></script>
<script src="${contextPath}/staticwx/qs/js/jquery.validate.min.js" type="text/javascript"></script>
<script src="${contextPath}/staticwx/qs/js/fastclick.js" type="text/javascript"></script>
<script src="${contextPath}/staticwx/qs/js/public.js" type="text/javascript"></script>
<script src="${contextPath}/staticwx/jweixin-1.0.0.js" type="text/javascript"></script>

<script>
    $(function(){
        /**************地址选择*********/
        $(".main-wrapper").on("click",".selectAddrBtn",function(){
            $(".addressBlc").show().animate({"right":"0%"},300);
        });
    
        /*************地址弹窗************/
        $(".addAddrBtn").click(function(){
            $("#realname").val("");
            $("#addrid").val("");
            $("#tel").val("");
            $("#cdetail").val("");
            $("#cprov").val("");
            $("#ccity").html('<option value="">请选择</option>')
            $("#cdiv").html('<option value="">请选择</option>') //区域
            $("#isdefault").val(0);
            $("#saveType").val(0);//保存类型改为修改
            $(".addAddr").show().animate({"left":"0%"},300);
        });

        $(".addAddr .header .hl").click(function(){
            $(".addAddr").animate({"left":"-100%"},300,function(){
                $(this).hide();
            });
        });

        $(".addressHead .close").click(function(){
            $(".addressBlc").animate({"right":"-100%"},300,function(){
                $(this).hide()
            });
        });
        $("#cprov").on("change",function () {
            var provinceId=$(this).val();
            getChildTag(provinceId,1);
        })
        $("#ccity").on("change",function () {
            var cityId=$(this).val();
            getChildTag(cityId,2);
        })

        $(".psList .radioBtn").on("click",function () {
            $("#payType").val($(this).data("paytype"));
        })
    });

    $("#addrForm").validate({
        ignore:"",
        rules:{
            realname:{required:true},
            tel:{required:true},
            provinceid:{required:true},
            cityid:{required:true},
            regionid:{required:true},
            addr:{required:true}
        },
        messages:{
            realname:{required:"请填写收货人名称！"},
            tel:{required:"请填写手机号码！"},
            provinceid:{required:"请选择省份！"},
            cityid:{required:"请选择城市！"},
            regionid:{required:"请选择区域！"},
            addr:{required:"请填写详细地址！"}
        },
        errorPlacement: function( error, element ) {
            error.insertAfter(element);
        },
        submitHandler: function(form) {
            saveAddr();
        },
        errorClass : "onError",
        errorElement: "div"
    });

    $(".popUpMask .btnCancel").click(function(){
        $(this).parents(".popUpMask").hide();
    });

    /*获取下级区域数据*/
    function getChildTag(parnetId,lv,childId) {
        $.ajax({
            url : '${contextPath}/tag/getChildList.htm',
            data : {
                pid : parnetId
            },
            type : 'post',
            cache : false,
            dataType : 'json',
            success : function(data) {
                var json = $.parseJSON(data);
                if (json.isSuccess == true) {
                    var list=json.tagList;
                    var html='<option valur="">请选择</option>';
                    $.each(list,function (i,tag) {
                        if(childId&&childId==tag.id){
                            html+='<option value="'+tag.id+' selected">'+tag.tname+'</option>';
                        }else{
                            html+='<option value="'+tag.id+'">'+tag.tname+'</option>';
                        }
                    })
                    if(lv==1){
                        $("#ccity").html(html);
                    }else if(lv==2){
                        $("#cdiv").html(html);
                    }

                } else {
                    showMsg(json.errMessage);
                }
            },
            error : function() {
                showMsg("异常");
            }
        });
    }
    /*保存地址簿数据*/
    function saveAddr(){
        $.ajax({
            url : '${contextPath}/wx/addr/saveAddr.htm',
            data : $("#addrForm").serialize(),
            type : 'post',
            cache : false,
            dataType : 'json',
            success : function(data) {
                var json = $.parseJSON(data);
                if (json.isSuccess == true) {
                    var addrvo=json.addrvo;
                    setAddrListData(addrvo);
                } else {
                    showMsg(json.errMessage);
                }
            },
            error : function() {
                showMsg("异常");
            }
        });
    }
    /*设置地址簿 列表内容*/
    function setAddrListData(addrvo){
        var saveType=$("#saveType").val();
        var html='';
        if(saveType==0){
            html+='<li id="addrli_'+addrvo.id+'">';
        }
        html+='<div class="clearfix">';
        html+='<span class="fl">'+addrvo.realname+'</span>';
        html+='<span class="fr">'+addrvo.tel+'</span>';
        html+='</div>';
        html+='<p>'+addrvo.provinceName+addrvo.cityName+addrvo.regionName+addrvo.addr+'</p>';
        html+='<div class="clearfix">';
        html+='<div class="fl checkarea">';
        html+='<span class="cblue" onclick="sendHere('+"'"+addrvo.id+"','"+addrvo.realname+"','"+addrvo.tel+"','"+addrvo.provinceName+"','"+addrvo.cityName+"','"+addrvo.regionName+"','"+addrvo.isdefault+"','"+addrvo.addr+"'"+')">&nbsp;送到这里去</span>';
        html+='</div>';
        html+='<span class="fr">';
        html+='<span class="editBtn" onclick="editAddr('+"'"+addrvo.id+"','"+addrvo.realname+"','"+addrvo.tel+"','"+addrvo.provinceid+"','"+addrvo.cityid+"','"+addrvo.regionid+"','"+addrvo.isdefault+"','"+addrvo.addr+"'"+')"><span class="iconfont icon-bianji"></span>&nbsp;编辑</span>';
        html+='&nbsp;&nbsp;'
        html+='<span class="delBtn" onclick="addrDelConfirm('+"'"+addrvo.id+"'"+')"><span class="iconfont icon-lajitong"></span>&nbsp;删除</span>';
        html+=' </span>';
        html+='</div>';
        if(saveType==0){
            html+='</li>';
        }
        if(saveType==0){
            $("#addrUl").html(html+$("#addrUl").html());
        }else{
            $("#addrli_"+addrvo.id).html(html);
        }
        $(".addAddr .header .hl").click();//关闭添加窗口
    }

    function editAddr(id,realname,tel,pid,cid,rid,isdefault,cdetail){
        $("#realname").val(realname);
        $("#addrid").val(id);
        $("#tel").val(tel);
        $("#cdetail").val(cdetail);
        $("#cprov").val(pid);
        setCityData(pid,cid,rid);
        $("#isdefault").val(isdefault);
        $("#saveType").val(1);//保存类型改为修改
        $(".addAddr").show().animate({"left":"0%"},300);
    }
    /*编辑地址-设置城市初始数据*/
    function setCityData(provinceId,cityId,regionId){
        $.ajax({
            url : '${contextPath}/tag/getChildList.htm',
            data : {
                pid : provinceId
            },
            type : 'post',
            cache : false,
            dataType : 'json',
            success : function(data) {
                var json = $.parseJSON(data);
                if (json.isSuccess == true) {
                    var cityList=json.tagList;
                    var html='<option valur="">请选择</option>';
                    $.each(cityList,function (i,tag) {
                        if(cityId==tag.id){
                            html+='<option value="'+tag.id+'" selected>'+tag.tname+'</option>';
                        }else{
                            html+='<option value="'+tag.id+'">'+tag.tname+'</option>';
                        }
                    })
                    $("#ccity").html(html);
                    setRegionData(cityId,regionId);
                } else {
                    showMsg(json.errMessage);
                }
            },
            error : function() {
                showMsg("异常");
            }
        });
    }
    /*编辑地址-设置区域初始数据*/
    function setRegionData(cityId,regionId){
        $.ajax({
            url : '${contextPath}/tag/getChildList.htm',
            data : {
                pid : cityId
            },
            type : 'post',
            cache : false,
            dataType : 'json',
            success : function(data) {
                var json = $.parseJSON(data);
                if (json.isSuccess == true) {
                    var regionList=json.tagList;
                    var html='<option valur="">请选择</option>';
                    $.each(regionList,function (i,tag) {
                        if(regionId==tag.id){
                            html+='<option value="'+tag.id+'" selected>'+tag.tname+'</option>';
                        }else{
                            html+='<option value="'+tag.id+'">'+tag.tname+'</option>';
                        }
                    })
                        $("#cdiv").html(html);
                } else {
                    showMsg(json.errMessage);
                }
            },
            error : function() {
                showMsg("异常");
            }
        });
    }
    /*删除地址确认框*/
    function addrDelConfirm(id){
        $("#delAddr").show();
        $("#delAddrId").val(id);

    }
    /*删除地址确认按钮*/
    function delAddr(){
        var id= $("#delAddrId").val();
        delAddrData(id);
    }
    /*删除地址 提交数据*/
    function delAddrData(id){
        $.ajax({
            url : '${contextPath}/wx/addr/delAddr.htm',
            data : {
                id : id
            },
            type : 'post',
            cache : false,
            dataType : 'json',
            success : function(data) {
                var json = $.parseJSON(data);
                if (json.isSuccess == true) {
                    $("#addrli_"+id).remove();
                    $("#delAddr").hide();
                    showMsg("删除成功");
                } else {
                    showMsg(json.errMessage);
                }
            },
            error : function() {
                showMsg("异常");
            }
        });
    }
    /*地址簿 送到这里去*/
    function sendHere(id,realname,tel,provinceName,cityName,regionName,isdefault,cdetail){
        $.ajax({
            url : '${contextPath}/wx/addr/sendHereSession.htm',
            data : {
                id : id
            },
            type : 'post',
            cache : false,
            dataType : 'json',
            success : function(data) {
                var json = $.parseJSON(data);
                if (json.isSuccess == true) {
                    $("#abId").val(id);
                    var html="";
                    html+='<div class="address selectAddrBtn" style="margin-top: 1px;">';
                    html+='<img src="${contextPath}/staticwx/qs/images/addrline.jpg" width="100%" alt="">';
                    html+='<div class="info">';
                    html+='<div class="detail">';
                    html+='<div class="clearfix">';
                    html+='<div class="fl">'+realname+'</div>';
                    html+='<div class="fr">'+tel+'</div>';
                    html+='</div>';
                    html+='<p>收货地址：'+provinceName+cityName+regionName+cdetail+'</p>';
                    html+='</div>';
                    html+='</div>';
                    html+='<img src="${contextPath}/staticwx/qs/images/addrline.jpg" width="100%" alt="">';
                    html+='</div>';
                    $("#headTop").next().remove();
                    $("#headTop").after(html);
                    $(".addressHead .close").click();
                } else {
                    showMsg(json.errMessage);
                }
            },
            error : function() {
                showMsg("异常");
            }
        });
    }
    /*提交订单数据*/
    function  subOrder() {
        var orderNo=$("#orderNo").val();
        var payType=$("#payType").val();
        if(orderNo){//表示订单已生成
            if(payType==1){
                var openId=$("#openId").val();
                var appId=$("#appId").val();
                var timeStamp=$("#timeStamp").val();
                var nonceStr=$("#nonceStr").val();
                var packages=$("#packages").val();
                var paySign=$("#paySign").val();
                callWxpay(appId,timeStamp,nonceStr,packages,paySign,orderNo);
                return false;
            }
        }else{
            var orderType=$("#orderType").val();//1-常规下单；2-充值订单;3-收款订单;
            var cityId=$("#cityId").val();
            var totalAmount=$("#totalAmount").val();
            var abId=$("#abId").val();
            var memberId=$("#memberId").val();
            var disType=$("#disType").val();
            var remark=$("#remark").val();
            if(!abId){
                showMsg("请选择收货地址！");
                return false;
            }
            createOrder(orderType,payType,cityId,totalAmount,abId,memberId,disType,remark);
        }

    }

    /*创建订单*/
    function createOrder(orderType,payType,cityId,totalAmount,abId,memberId,disType,remark){
        $.ajax({
            url : '${contextPath}/wx/order/createOrder.htm',
            data : {
                totalAmount:$("#totalAmount").val(),
                remark:$("#remark").val(),
                memberId:$("#memberId").val(),
                orderType:$("#orderType").val(),
                payType:$("#payType").val(),
                abId:$("#abId").val(),
                cityId:$("#cityId").val(),
                disType:$("#disType").val()
            },
            type : 'post',
            cache : false,
            dataType : 'json',
            success : function(data) {
                var json = $.parseJSON(data);
                if (json.isSuccess == true) {
                    var orderNo=json.orderNo;
                    var openId=$("#openId").val();
                    $("#orderNo").val(orderNo);
                    if(payType==1){
                        doWxPay(orderNo,openId);
                    }else if(payType==2||payType==3){
                        location.href="${contextPath}/wx/wxpay/result.htm?oid="+orderNo+"&&result=SUCCESS";
                    }
                }else{
                    showMsg(json.errMessage);
                }
            },
            error : function() {
                //alert("订单提交异常！");
            }
        });
    }

    /*获取微信支付设置*/
    function doWxPay(orderNo,openId){
        $.ajax({
            url : '${contextPath}/wx/wxpay/fastPay.htm',
            data : {orderNo:orderNo,openId:openId},
            type : 'post',
            cache : false,
            dataType : 'json',
            success : function(data) {
                var json = $.parseJSON(data);
                if (json.isSuccess == true) {
                    var appId=json.appId;
                    var timeStamp=json.timeStamp;
                    var nonceStr=json.nonceStr;
                    var packages=json.packages;
                    var paySign=json.sign;
                    $("#appId").val(appId);
                    $("#timeStamp").val(timeStamp);
                    $("#nonceStr").val(nonceStr);
                    $("#packages").val(packages);
                    $("#paySign").val(paySign);
                    callWxpay(appId,timeStamp,nonceStr,packages,paySign,orderNo);
                }else{
                    showMsg(data.msg);
                }
            },
            error : function() {
                //alert("订单提交异常！");
            }
        });

    }
    /*发起微信支付*/
    function callWxpay(appId,timeStamp,nonceStr,packages,sign,orderNo){
        var appId=appId;
        var timeStamp=timeStamp;
        var nonceStr =nonceStr;
        var packages=packages;
        var paySign=sign;
        WeixinJSBridge.invoke('getBrandWCPayRequest',{
            "appId" : appId,"timeStamp" : timeStamp, "nonceStr" : nonceStr, "package" : packages,"signType" : "MD5", "paySign" : paySign
        },function(res){
            WeixinJSBridge.log(res.err_msg);
            if(res.err_msg == "get_brand_wcpay_request:ok"){
                location.href="${contextPath}/wx/wxpay/result.htm?oid="+orderNo+"&result=SUCCESS";
            }else if(res.err_msg == "get_brand_wcpay_request:cancel"){
                alert("支付取消!");
            }else{
                alert(res.err_msg);
                alert("支付失败!");
            }
        })
    }
</script>
</body>
</html>